#pragma once
#include <iostream>
#include <string>

std::string opers="+-*/%";
enum
{
    div_zero = 1, // 除0错误
    Mod_zero = 2, //取模错误
    Unknown=3    //运算符不存在
};
class Task
{
public:
    Task(int x, int y, char op)
        : data1_(x), data2_(y), oper_(op), result_(0), exitcode_(0)
    {
    }
    void run()
    {
        switch (oper_)
        {
        case '+':
            result_ = data1_ + data2_;
            break;
        case '-':
            result_ = data1_ - data2_;
            break;
        case '*':
            result_ = data1_ * data2_;
            break;
        case '/':
        {
            if (data2_ == 0)
                exitcode_ = div_zero;
            else
                result_ = data1_ / data2_;
        }
        break;
        case '%':
        {
            if(data2_==0) exitcode_=Mod_zero;
            else result_=data1_/data2_;
        }
            break;
        default:
            exitcode_=Unknown;
            break;
        }
    }
    std::string GetResult()
    {
        std::string r=std::to_string(data1_);
        r+=oper_;
        r+=std::to_string(data2_);
        r+='=';
        r+=std::to_string(result_);
        r+='[';
        r+=std::to_string(exitcode_);
        r+=']';
        return r;
    }
    std::string GetTask()
    {
        std::string r=std::to_string(data1_);
        r+=oper_;
        r+=std::to_string(data2_);
        r+='=';
        r+="? ? ?";
        return r;
    }
    ~Task()
    {
    }

private:
    int data1_;
    int data2_;
    char oper_; // 运算方式

    int result_;
    int exitcode_;
};